package cn.qingyun.gis.modules.youshang.entity.dto;

import cn.hutool.core.util.ObjectUtil;
import cn.qingyun.gis.modules.init.system.convert.CustomizeImageConverter;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Data
@ApiModel(value = "导出友商勘误对象")
public class ExportYsChannelDto {
    /**
     * 主键id = 唯一记录号
     */
    @ExcelProperty("唯一记录号")
    @ApiModelProperty(value = "唯一记录号")
    private String id;

    /**
     * 渠道名称
     */
    @ExcelProperty("渠道名称")
    @ApiModelProperty(value = "渠道名称")
    private String ysChannelName;

    /**
     * 点位状态 (有效/无效)
     */
    @ExcelProperty("点位状态")
    @ApiModelProperty(value = "点位状态")
    private String pointStatue;

    /**
     * 渠道地址(归属省份+地市+县区+详细地址)
     */
    @ExcelProperty("渠道地址")
    @ApiModelProperty(value = "渠道地址")
    private String ysChannelAddress;

    /**
     * POI-ID
     */
    @ExcelProperty("POI-ID")
    @ApiModelProperty(value = "POI-ID")
    private String poiId;

    /**
     * POI-Name
     */
    @ExcelProperty("POI-Name")
    @ApiModelProperty(value = "POI-Name")
    private String poiName;

    /**
     * 经度
     */
    @ExcelProperty("经度")
    @ApiModelProperty(value = "经度")
    private BigDecimal lon;

    /**
     * 纬度
     */
    @ExcelProperty("纬度")
    @ApiModelProperty(value = "纬度")
    private BigDecimal lat;

    /**
     * 归属地市编码
     */
    @ExcelProperty("归属地市编码")
    @ApiModelProperty(value = "归属地市编码")
    private String regionCityCode;

    /**
     * 归属网格编码
     */
    @ExcelProperty("归属网格编码")
    @ApiModelProperty(value = "归属网格编码")
    private String gridId;

    /**
     * 归属微网格编码
     */
    @ExcelProperty("归属微网格编码")
    @ApiModelProperty(value = "归属微网格编码")
    private String mircoGridId;


    /**
     * 0：正常经营| 1：关门营业
     */
    @ExcelProperty("经营现状")
    @ApiModelProperty(value = "0：正常经营| 1：关门营业")
    private String operateState;

    /**
     * 归属运营商
     */
    @ExcelProperty("归属运营商")
    @ApiModelProperty(value = "归属运营商")
    private String belongOperator;

    /**
     * 友商渠道一级类型（0：运营商自办厅，1：代办厅（无手机销售），2：代办厅（有手机销售））
     */
    @ExcelProperty("渠道一级类型")
    @ApiModelProperty(value = "友商渠道一级类型（0：运营商自办厅，1：代办厅（无手机销售），2：代办厅（有手机销售））")
    private String channelOneType;

    /**
     * 友商渠道二级类型
     */
    @ExcelProperty("渠道二级类型")
    @ApiModelProperty(value = "友商渠道二级类型")
    private String channelTwoType;


    /**
     * 房屋类型(0:运营商自有房产，1:运营商租赁房产，2:代理商自有房产，1:代理商租赁房产)
     */
    @ExcelProperty("房屋类型")
    @ApiModelProperty(value = "房屋类型(0:运营商自有房产，1:运营商租赁房产，2:代理商自有房产，1:代理商租赁房产)")
    private String houseType;

    /**
     * 房屋面积(平方米)
     */
    @ExcelProperty("房屋面积")
    @ApiModelProperty(value = "房屋面积(平方米)")
    private String floorSpace;

    /**
     * 老板姓名
     */
    @ExcelProperty("老板姓名")
    @ApiModelProperty(value = "老板姓名")
    private String bossName;

    /**
     * 老板联系电话
     */
    @ExcelProperty("老板联系电话")
    @ApiModelProperty(value = "老板联系电话")
    private String bossPhone;

    /**
     * 渠道门头照片1
     */

    @ExcelProperty(value = "渠道门头照片1", converter = CustomizeImageConverter.class)
    @ApiModelProperty(value = "渠道门头照片1")
    private String channelPictureOne;

    /**
     * 渠道门头照片2
     */
    @ExcelProperty(value = "渠道门头照片2", converter = CustomizeImageConverter.class)
    @ApiModelProperty(value = "渠道门头照片2")
    private String channelPictureTwo;

    /**
     * 渠道门头照片3
     */
    @ExcelProperty(value = "渠道门头照片3", converter = CustomizeImageConverter.class)
    @ApiModelProperty(value = "渠道门头照片3")
    private String channelPictureThree;

    /**
     * 摸排人工号
     */
    @ExcelProperty("摸排人工号")
    @ApiModelProperty(value = "摸排人工号")
    private String kwPhone;


    @ExcelProperty("更新时间")
    @ApiModelProperty(value = "更新时间")
    private String updateTime;

    public String getOperateState() {
        if ("0".equals(operateState)) {
            return "正常经营";
        }
        if ("1".equals(operateState)) {
            return "关门营业";
        }
        return operateState;
    }

    public void setOperateState(String operateState) {
        this.operateState = operateState;
    }

    public String getBelongOperator() {
        if (ObjectUtil.isNotEmpty(belongOperator)) {
            List<String> reasonList = Arrays.asList(belongOperator.split("\\|"));
            List<String> newReasonList = new ArrayList<>();
            if (!reasonList.isEmpty()) {
                for (int index = 0; index < reasonList.size(); index++) {
                    if ("0-Aa".equals(reasonList.get(index))) {
                        newReasonList.add("联通");
                    }
                    if ("1-Bb".equals(reasonList.get(index))) {
                        newReasonList.add("电信");
                    }
                    if ("2-Cc".equals(reasonList.get(index))) {
                        newReasonList.add("广电");
                    }
                    if ("3-Dd".equals(reasonList.get(index))) {
                        newReasonList.add("移动");
                    }
                    if ("4-Ee".equals(reasonList.get(index))) {
                        newReasonList.add("均未合作");
                    }
                }
                return String.join("|", newReasonList);
            }
        }
        return belongOperator;
    }

    public void setBelongOperator(String belongOperator) {
        this.belongOperator = belongOperator;
    }

    public String getChannelOneType() {
        if ("0".equals(channelOneType)) {
            return "运营商自办厅";
        }
        if ("1".equals(channelOneType)) {
            return "代办厅（无手机销售）";
        }
        if ("2".equals(channelOneType)) {
            return "代办厅（有手机销售）";
        }
        return channelOneType;
    }

    public void setChannelOneType(String channelOneType) {
        this.channelOneType = channelOneType;
    }

    public String getChannelTwoType() {
        if ("1".equals(channelOneType)) {
            return "非品专店";
        }
        if ("2".equals(channelOneType)) {
            return "OPPO品专店";
        }
        if ("3".equals(channelOneType)) {
            return "vivo品专店";
        }
        if ("4".equals(channelOneType)) {
            return "荣耀品专店";
        }
        if ("5".equals(channelOneType)) {
            return "华为品专店";
        }
        if ("6".equals(channelOneType)) {
            return "小米品专店";
        }
        if ("7".equals(channelOneType)) {
            return "苹果品专店";
        }
        if ("8".equals(channelOneType)) { // 8|备注信息
            return "其他(" + channelOneType.split("\\|")[1]+ ")";
        }
        return channelTwoType;
    }

    public void setChannelTwoType(String channelTwoType) {
        this.channelTwoType = channelTwoType;
    }

    public String getHouseType() {
        if ("0".equals(houseType)) {
            return "运营商自有房产";
        }
        if ("1".equals(houseType)) {
            return "运营商租赁房产";
        }
        if ("2".equals(houseType)) {
            return "代理商自有房产";
        }
        if ("3".equals(houseType)) {
            return "代理商租赁房产";
        }
        return houseType;
    }

    public void setHouseType(String houseType) {
        this.houseType = houseType;
    }

}
